// event-bus.js
// import Vue from 'vue';
//
// export const EventBus = new Vue();

const events = {};

export const emitter = {
    on(event, handler) {
        if (!events[event]) events[event] = [];
        events[event].push(handler);
    },
    emit(event, payload) {
        if (events[event]) {
            events[event].forEach(handler => handler(payload));
        }
    },
    off(event, handler) {
        if (events[event]) {
            events[event] = events[event].filter(h => h !== handler);
        }
    }
};
